/**
 * Created by Administrator on 2017\9\20 0020.
 * 套餐详情组件
 */
import React from 'react';
import template from './../../commonui/template';
import { Link } from 'react-router-dom';
import {Button,DatePicker,Upload,message,Icon} from 'antd';
const {MonthPicker,RangePicker} =DatePicker;
import cookie from './../../commonui/cookie';

class PackageDetail extends React.Component{
    constructor(props){
        super(props);
         const user=cookie.get('user');
        const lb=cookie.get('lb');
        this.state={
            user:user,
            lb:lb,
            info:{
                Name:this.props.info.Name,
                Address:this.props.info.Address,
                Phone:this.props.info.Phone,
                WorkTime:this.props.info.WorkTime,
                Poster:this.props.info.Poster
            },
            package:{
                Name:this.props.package.Name,
                Introduction:this.props.package.Introduction,
                Content:this.props.package.Content,
                Price:this.props.package.Price,
                ResrveTime:this.props.package.ResrveTime
            }
        }
        this.RerserveDetail=this.RerserveDetail.bind(this);
        this.dateChange=this.dateChange.bind(this);
    }
    dateChange(date,dateString){
        console.log(date,dateString);
    }
    RerserveDetail(){
        if(this.state.lb ==='Personal'){
            /**********ajax 获取个人可预约信息及价格***************/
            return (
                <div>
                    <h4>46</h4>
                    <button>Reserve</button>
                    <div>
                        <p>Optional Time</p>
                        <p></p>
                        <p></p>
                        <DatePicker onChange={this.dateChange} />
                    </div>
                </div>
            )
        }else{
            const upload={
                  name: 'file',
                  action: '//jsonplaceholder.typicode.com/posts/',
                  headers: {
                    authorization: 'authorization-text',
                  },
                  onChange(info) {
                    if (info.file.status !== 'uploading') {
                      console.log(info.file, info.fileList);
                    }
                    if (info.file.status === 'done') {
                      message.success(`${info.file.name} file uploaded successfully`);
                    } else if (info.file.status === 'error') {
                      message.error(`${info.file.name} file upload failed.`);
                    }
                  },
            };
            return (
                 <div>
                     <h3>38</h3>
                     <button>Reserve</button>
                     <div>
                         <a href="./../../fatchData/test.txt" download="test.txt">下载示例</a>
                        {/* <Upload {...upload}>
                                <Button>
                                  <Icon type="upload" /> Click to Upload
                                </Button>
                        </Upload>*/}
                     </div>

                 </div>
            )
        }
    }
    render(){
        return (
            <div>
                <div>
                    <h3>{this.state.package.Name}</h3>
                </div>
                <div>
                    <div>
                        <p>{this.state.Introduction}</p>
                    </div>
                    <div>
                          <p>{this.state.Content}</p>
                    </div>
                </div>
                <div>
                    {this.RerserveDetail()}
                </div>
            </div>
        )
    }
}

export default template({
    id: 'PackageDetail',
    component: PackageDetail
});
